//
//  CommonFunc.swift
//  Browser
//
//  Created by 刘光华 on 16/4/28.
//  Copyright © 2016年 liuguanghua. All rights reserved.
//

import UIKit

/// 根据图片计算imageView的高度
func calculateImageViewHeight(image: UIImage) -> CGRect {
    
    let imageW = image.size.width
    let imageH = image.size.height
    
    let x: CGFloat = 0
    let width = UIScreen.mainScreen().bounds.size.width
    let height = imageH * width / imageW
    let y = (UIScreen.mainScreen().bounds.size.height - height) * 0.5
    
    let rect = CGRect(x: x, y: y, width: width, height: height)
    
    return rect
    
    
}